define(['require', 'app', 'angularAMD', 'angular', 'angular-route'], function (require, app, angularAMD, angular) {
	configBaseView.$inject = ['$stateProvider', '$urlRouterProvider', 'pathPrefix', '$controllerProvider']
	function configBaseView($stateProvider, $urlRouterProvider, pathPrefix, $controllerProvider) {
		var studentPath = pathPrefix + 'components/student';
		$stateProvider.state('student', {
			'abstract': true,
			url: '/student',
			templateUrl: studentPath + '/main.html',
			resolve: {
				pre: function ($http, $rootScope, $q) {
					if ($rootScope.$signUpInfo) {
						return $q.when(1)
					}
					return $http.post(':root/trainee/getByXh', {
						xh: $rootScope.$user.uid
					}).success(function (r) {
						$rootScope.$signUpInfo = r || {}
					})
				},
				directive: function ($q) {
					var defer = $q.defer()
					require(['ngload!angular-chosen', 'root/components/common/modal/modal', 'ngload!angular-toggle-switch'], function () {
						defer.resolve()
					})
					return defer.promise
				}
			},

		})
		$stateProvider.state('student.default', {
			url: '',
			parent: 'student',
			controller: function ($state, $rootScope) {
				if ($rootScope.$signUpInfo.user) {
					$state.go('student.home')
				} else {
					$state.go('student.signUp')
				}
			},
			template: ''
		})
		$stateProvider.state('student.home', {
			url: '/home',
			parent: 'student',
			templateUrl: studentPath + '/home.html'
		})
		$stateProvider.state('student.course', {
			url: '/course',
			parent: 'student',
			templateUrl: studentPath + '/course.html'
		})
		$stateProvider.state('student.score', {
			url: '/score',
			parent: 'student',
			templateUrl: studentPath + '/score.html',
			resolve: {
				directive: function ($q) {
					var defer = $q.defer()
					require(['root/components/common/toaster', 'root/components/common/time/datetimepicker',
						'root/components/common/upload/upload'], function () {
							defer.resolve()
						})
					return defer.promise
				}
			}
		})
		$stateProvider.state('student.attendance', {
			url: '/attendance',
			parent: 'student',
			templateUrl: studentPath + '/attendance.html',
			resolve: {
				directive: function ($q) {
					var defer = $q.defer()
					require(['root/components/common/toaster', 'root/components/common/upload/upload'], function () {
						defer.resolve()
					})
					return defer.promise
				}
			}
		})
		$stateProvider.state('student.message', {
			url: '/message',
			parent: 'student',
			templateUrl: studentPath + '/message.html'
		})
		$stateProvider.state('student.signUp', {
			url: '/signUp',
			parent: 'student',
			resolve: {
				directive: function ($q) {
					var defer = $q.defer()
					require(['ngload!angular-toggle-switch', 'root/components/common/modal/modal'], function () {
						defer.resolve()
					})
					return defer.promise
				}
			},
			templateUrl: studentPath + '/signUp.html'
		})
	}
	angularAMD.config(configBaseView)

})